<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,user-scalable=no" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
		<link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
		<link rel="stylesheet" type="text/css" href="/public/static/wx/css/login.css" />
		<script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
		<script src="/public/static/wx/js/sweetalert-master/docs/assets/sweetalert/sweetalert.min.js" type="text/javascript" charset="utf-8"></script>

		<title>第三方登录</title>
	</head>

	<body>
		<div class="index">
			<div class="top-img">
				<img src="/public/static/wx/img/login/logo.png" />
			</div>
			<div class="input-list">
				<div class="input-box clearfix">
					<img src="/public/static/wx/img/login/people.png"/>
					<input type="text" d-name="username" placeholder="请输入账号" />
					<input type="text"  style="height: 0;border-color: #fff"/>
				</div>
				<div class="input-box clearfix">
					<img src="/public/static/wx/img/login/password.png"/>
					<input type="password" d-name="pass" placeholder="请输入密码" />
					<!--<a href="#">忘记密码？</a>-->
				</div>
				<div class="input-box clearfix">
					<img src="/public/static/wx/img/login/safe.png"/>
					<input type="text" d-name="code" placeholder="请输入验证码" />
					<div class="ercode"><img src="{:url("login/code")}?" onclick="this.src=this.src+'1'" alt="" style="width:100%;heigh:100%"></div>
				</div>
			</div>
			<div class="login">登录</div>
			<!--<div class="register">还没账号？
				<a href="#">立即注册</a>
			</div>-->
		</div>
		<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">

            // $(function(){
            //     $.post('{:url("login/code")}',function(callback){
            //         console.log(callback)
				// 	// $('.ercode img').attr('src',callback)
            //     })
            // })

			$('.login').on('click', function() {
				var dobj = {};

				$('[d-name]').each(function() {
					dobj[$(this).attr('d-name')] = $.trim($(this).val());
				});

				if(dobj.code == ''){

                    swal({
                        text: '请输入验证码',
                        icon: 'error',
                        timer: '2000',
                        button: false,
                    });
				    return;
				}
				// var password = md5(dobj.password);
				// dobj.password = password;

				$.post('{:url("login/login")}', dobj, function(callback) {
					if(callback.code == 1) {
                        swal({
                            text: callback.msg,
                            icon: 'success',
                            timer: '2000',
                            button: false,
                        });
						window.location.href = '{:url("Enter/index")}'
					}
					else{
                        swal({
                            text: callback.msg,
                            icon: 'error',
                            timer: '2000',
                            button: false,
                        });
                        var src = $('.ercode img').attr('src');
                        $('.ercode img').attr('src',src+"?time="+Math.random())
					}
				})

			});
		</script>
	</body>

</html>